package upload

import (
	"crypto/tls"
	"encoding/json"

	"github.com/astaxie/beego/httplib"
)

func GetUploadPara(url string) (para Para, err error) {
	req := httplib.Get(url)
	req.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
	bytes, err := req.Bytes()
	if err != nil {
		return
	}
	err = json.Unmarshal(bytes, &para)
	if err != nil {
		return
	}
	//fmt.Println("para : ", para)
	return
}

func GetFile(link Link, path string) {
	req := httplib.Get(link.Url)
	req.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
	req.ToFile(path + link.Name)
}
